<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;


// dingo api 的实例
$api = app('Dingo\Api\Routing\Router');

// 中间件处理
$params = [
    'middleware' => ['api.throttle', 'bindings', 'serializer:array'],
    'limit' => 60,
    'expires' => 1
];

//使用 api.throttle 来设置访问节流  limit 设置访问的次数  expires 设置时间的限定
$api->version('v1', $params, function ($api) {

    // 微信公众号菜单
    $api->group(['prefix' => 'wx_menus'], function ($api) {
        $api->resource('/', \App\Http\Controllers\WeChat\WeChatMenuController::class, [
            'only' => ['index', 'store']
        ]);
    });

    //公众号菜单
    $api->resource('/wx_menus', \App\Http\Controllers\WeChat\WeChatMenuController::class, [
        'only' => ['index', 'store']
    ]);

    //前台用户登录
    $api->group(['prefix' => 'home'], function ($api) {
        //前台用户登录

        $api->group(['prefix' => 'home'], function ($api) {
            //前台用户登录
            $api->post('login', [\App\Http\Controllers\Home\LoginController::class, 'login']);
            //获取登录用户的信息
            $api->get('my', [\App\Http\Controllers\Home\LoginController::class, 'me']);
            //刷新登录用户的token值
            $api->post('refresh/token', [\App\Http\Controllers\Home\LoginController::class, 'refresh']);
            //退出登录
            $api->post('logout', [\App\Http\Controllers\Home\LoginController::class, 'logout']);
            $api->get('/test', [\App\Http\Controllers\TestController::class, 'show']);
        });
        //$api->get('/test', [\App\Http\Controllers\TestController::class,'show']);
    });
});





